﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;

using System.Text;
using System.Windows.Forms;
using QUANLYCHAMCONG.BL.BUS;

namespace QUANLYCHAMCONG.PL.CMS.Maychamcong
{
    public partial class ToolbarMayChamCong : UserControl
    {
        #region "Event"
        /// <summary>
        /// delace deleagate for event
        /// </summary>
        public delegate void _EventHander();
        /// <summary>
        /// area event 
        /// </summary>
        public event _EventHander Download;
        public event _EventHander Upload;
        public event _EventHander Remove;
        public event _EventHander Delete;
        public event _EventHander Save;
        public event _EventHander Restart;
        public event _EventHander Syssnc;
        public event _EventHander Clock;
        public event _EventHander Exit;
        public event _EventHander ChangeMachine;
        #endregion
        //nap du lieu
        private DataTable _DataLoaiMay;
        public DataTable DataLoaiMay
        {
            get { return _DataLoaiMay; }
            set { _DataLoaiMay = value; }
        }
        private string _DisplayMember;
        public string DisplayMember
        {
            get { return _DisplayMember; }
            set { _DisplayMember = value; }
        }
        private string _ValuesMember;
        public string ValuesMember
        {
            get { return _ValuesMember; }
            set { _ValuesMember = value; }
        }
        private bool _Visible;
        public bool Visible
        {
            get { return _Visible; }
            set { _Visible = value; }
        }
        private string _SelectValue;
        public string SelectValue
        {
            get { return _SelectValue; }
            set { _SelectValue = value; }
        }
        public ToolbarMayChamCong()
        {
            InitializeComponent();
        }
        private void btndown_Click(object sender, EventArgs e)
        {
            if (this.Download != null)
                this.Download();
        }
        private void btnup_Click(object sender, EventArgs e)
        {
            if (this.Upload != null)
                this.Upload();
        }
        private void btnremove_Click(object sender, EventArgs e)
        {
            if (this.Remove != null)
                this.Remove();
        }
        private void btndelete_Click(object sender, EventArgs e)
        {
            if (this.Delete != null)
                this.Delete();
        }
        private void btnsave_Click(object sender, EventArgs e)
        {
            if (this.Save != null)
                this.Save();
        }
        private void btnrestart_Click(object sender, EventArgs e)
        {
            if (this.Restart != null)
                this.Restart();
        }
        private void btnsyssnc_Click(object sender, EventArgs e)
        {
            if (this.Syssnc != null)
                this.Syssnc();
        }
        private void btnclock_Click(object sender, EventArgs e)
        {
            if (this.Clock != null)
                this.Clock();
        }
        private void btnexit_Click(object sender, EventArgs e)
        {
            if (this.Exit != null)
                this.Exit();
        }
        public void AddDataForCMB()
        {
            Common.AddDataForCombobox(ref this.comboBox2, ref _DataLoaiMay, DisplayMember, ValuesMember);
        }
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.ChangeMachine != null)
            {
                this.SelectValue = this.comboBox2.SelectedValue.ToString();
                this.ChangeMachine();
            }
        }
        public void ActiveFillter()
        {
            if (this.Visible)
            {
                comboBox2.Visible = true;
            }
            else
            {
                comboBox2.Visible = false;
            }
        }
        public void SetEnableButton(bool down, bool up, bool remove, bool delete, bool save, bool restart, bool sysn, bool clock, bool exit)
        {
            if (down)
                btndown.Enabled = true;
            else
                btndown.Enabled = false;
            if (up)
                btnup.Enabled = true;
            else
                btnup.Enabled = false;
            if (remove)
                btnremove.Enabled = true;
            else
                btnremove.Enabled = false;
            if (delete)
                btndelete.Enabled = true;
            else
                btndelete.Enabled = false;
            if (save)
                btnsave.Enabled = true;
            else
                btnsave.Enabled = false;
            if (restart)
                btnrestart.Enabled = true;
            else
                btnrestart.Enabled = false;
            if (sysn)
                btnsyssnc.Enabled = true;
            else
                btnsyssnc.Enabled = false;
            if (clock)
                btnclock.Enabled = true;
            else
                btnclock.Enabled = false;
            if (exit)
                btnexit.Enabled = true;
            else
                btnexit.Enabled = false;
        }
    }
}
